package com.newlink.building.main.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.newlink.building.common_base.model.bean.PropertyManagerData
import com.newlink.building.common_base.model.bean.RoomData
import com.newlink.building.common_base.model.bean.RoomUserData
import com.newlink.building.main.R

/**
 * Created by xiaodong on 2022/8/30.
 */
class Module_Main_ResidentSearchAdapter(data: MutableList<Any>) :
    BaseQuickAdapter<Any, BaseViewHolder>(R.layout.item_resident_search, data) {
    init {
        addChildClickViewIds(R.id.rlContainer)
    }

    override fun convert(holder: BaseViewHolder, item: Any) {

        when (item) {
            is RoomData -> {
                holder.setText(R.id.tvRoomNumber, item.roomNo)
                holder.setText(R.id.tvRoomName, item.roomName)
                holder.setImageDrawable(
                    R.id.iv_room,
                    context.getDrawable(R.drawable.icon_resident_room)
                )
                holder.setGone(R.id.iv_arrow, false)
                holder.setGone(R.id.iv_call, true)
            }

            is PropertyManagerData -> {
                holder.setText(R.id.tvRoomNumber, context.getString(R.string.property_manager))
                holder.setText(R.id.tvRoomName, item.name)
                holder.setImageDrawable(
                    R.id.iv_room,
                    context.getDrawable(R.drawable.icon_property_manager_border)
                )
                holder.setGone(R.id.iv_arrow, true)
                holder.setGone(R.id.iv_call, false)
            }

            is RoomUserData -> {
                holder.setText(R.id.tvRoomNumber, context.getString(R.string.resident_str))
                holder.setText(R.id.tvRoomName, item.name)
                holder.setImageDrawable(
                    R.id.iv_room,
                    context.getDrawable(R.drawable.icon_room_user)
                )
                holder.setGone(R.id.iv_arrow, true)
                holder.setGone(R.id.iv_call, false)
            }
        }
    }
}